package com.yunhai.device.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yunhai.common.dto.PaginationVo;
import com.yunhai.common.dto.Ret;
import com.yunhai.device.service.CrrMaterialScrapReportService;
import com.yunhai.model.entity.crr.CrrMaterialScrapReportEntity;
import com.yunhai.model.vo.crr.CrrMaterialScrapReportQuery;
import com.yunhai.model.vo.crr.CrrMaterialScrapReportVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/crrMaterialScrapReport")
public class CrrMaterialScrapReportController {

	@Resource
	private CrrMaterialScrapReportService crrMaterialScrapReportService;


	/**
	 * 获取 CrrMaterialScrapReport 分页列表
	 */
	@GetMapping("/pagination")
	public Ret getCrrMaterialScrapReportPagination(PaginationVo paginationVo, CrrMaterialScrapReportQuery crrMaterialScrapReportQuery ) throws Exception {
		IPage page = crrMaterialScrapReportService.getCrrMaterialScrapReportPagination(paginationVo, crrMaterialScrapReportQuery );
		return Ret.toPage(page);
	}


	/**
	 * 获取 CrrMaterialScrapReport 所有数据
	 */
	@GetMapping("/allList")
	public Ret getCrrMaterialScrapReportAllList( CrrMaterialScrapReportQuery crrMaterialScrapReportQuery ) throws Exception {
		List<CrrMaterialScrapReportEntity> list = crrMaterialScrapReportService.getCrrMaterialScrapReportAllList( crrMaterialScrapReportQuery );
		return Ret.ok(list);
	}


	/**
	 * 获取 CrrMaterialScrapReport 详情
	 */
	@GetMapping("/{id}")
	public Ret getCrrMaterialScrapReportDetailById(@PathVariable Long id) throws Exception {

	    CrrMaterialScrapReportEntity crrMaterialScrapReportEntity = crrMaterialScrapReportService.getCrrMaterialScrapReportDetail(id);
		return Ret.ok(crrMaterialScrapReportEntity);
	}


	/**
	 * 新增 CrrMaterialScrapReport
	 * */
	@PostMapping("")
	public Ret addCrrMaterialScrapReport(@RequestBody CrrMaterialScrapReportVo crrMaterialScrapReportVo) throws Exception {

		crrMaterialScrapReportService.addCrrMaterialScrapReport(crrMaterialScrapReportVo);
		return Ret.ok();
	}


	/**
	 * 更新 CrrMaterialScrapReport
	 * */
	@PutMapping("")
	public Ret updateCrrMaterialScrapReport(@RequestBody CrrMaterialScrapReportVo crrMaterialScrapReportVo) throws Exception {

		crrMaterialScrapReportService.updateCrrMaterialScrapReport(crrMaterialScrapReportVo);
		return Ret.ok();
	}


	/**
	 * 删除 CrrMaterialScrapReport
	 * */
	@PostMapping("/batchRemove")
	public Ret batchRemoveCrrMaterialScrapReport( @RequestBody List<Long> ids ) throws Exception {

	    crrMaterialScrapReportService.batchRemoveCrrMaterialScrapReport(ids);
		return Ret.ok();
	}
}
